#pragma once

#include "ElasticMaterial.h"
#include "Vector3d.h"
#include "PointParticle.h"
#include "GL/glut.h"

class HangingCloth {
private:
    int numX, numY;
    double spacingX, spacingY;

    PointParticle* particles;

    Vector3d base, dir;

    PointParticle& getParticle(int x, int y) const;
    Vector3d& getPos(int x, int y) const;

    Vector3d getNormal(int x, int y) const;

    void applyForces();
public:
    ElasticMaterial material;

    HangingCloth(int numX, int numY, const Vector3d& base, const Vector3d& dirX, const Vector3d& dirY, ElasticMaterial& material);
    ~HangingCloth();

    void render() const;

    void eulerUpdate(double dt);

    void velocityVerletUpdate(double dt);

    void move(const Vector3d& diff);

    void rotate(double angleLeft, double angleUp);
};
